package com.zl.data.config;

import android.net.Uri;
import android.text.TextUtils;
import com.zl.data.util.FileUtil;

import java.io.File;

/**
 * @author ZL @朱林</a>
 * @Version 1.0
 * @Description TODO
 * @date 2021/01/08  14:40
 */
public class DataConstant {
    public static final String TAG = "DataStore";

    public static final int DATABASE_VERSION = 1;

    public static String BASE_DATABASE_NAME = "DataStore.db";

    public static String DATABASE_NAME;

    public static final String DATA_STORE_AUTHORITY = "com.zl.data.DataProvider";

    public static final Uri AUTHORITY_URI = Uri.parse("content://" + DATA_STORE_AUTHORITY);

    public static String getDatabaseName() {
        if (TextUtils.isEmpty(DATABASE_NAME)) {
            DATABASE_NAME = BASE_DATABASE_NAME;
        }
        return DATABASE_NAME;
    }

    public static void setDatabasePath(String databasePath) {
        FileUtil.createFile(databasePath, BASE_DATABASE_NAME);
        DATABASE_NAME = databasePath + File.separator + BASE_DATABASE_NAME;
    }
}
